import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:zenge_web_flutter/custom/appBar_widget.dart';
import 'package:zenge_web_flutter/custom/custom_widget.dart';
import 'package:zenge_web_flutter/view/keep_alive.dart';

import 'state.dart';

Widget buildView(
    ProductsState state, Dispatch dispatch, ViewService viewService) {
  TextStyle style4 =
      TextStyle(fontSize: 14, color: Color.fromRGBO(126, 146, 177, 1));
  TextStyle style2 = TextStyle(
    fontSize: 14,
    color: Colors.grey,
  );
  double screenWidth = 1920;
  return Scaffold(
    body: Container(
      width: MediaQuery.of(viewService.context).size.width,
      alignment: Alignment.center,
      child: Container(
        width: screenWidth,
        alignment: Alignment.center,
        child: ListView(
          shrinkWrap: true,
          controller: state.scrollController,
          children: [
            Stack(
              children: [
                Positioned(
                  top: 215,
                  child: Container(
                    width: screenWidth,
                    height:  605 / 1920 * screenWidth,
                    child: new Image.network(
                      'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2290940.jpg',
                      fit: BoxFit.fill,
                    ),
                  ),
                ),
                Positioned(
                  top: 65,
                  child: Container(
                    width: screenWidth,
                    height: 150/1920*screenWidth,
                    child: new Image.network(
                      'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2170934.jpg',
                      fit: BoxFit.fill,
                    ),
                  ),
                ),
                AppBarWidget(
                  boxHeight: 755,
                ),
              ],
            ),
            ImageWidget(
              width: screenWidth,
              height: 605 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2290941.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 605 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2291059.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 605 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2291060.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 605 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3604/18024687/images/3679948.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 605 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3604/18024687/images/3679949.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 552 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2167921.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 720 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2220743.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 900 / 1920 * screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2220779.jpg',
            ),
            KeepAliveWidget(viewService.buildComponent("bottom_info")),
          ],
        ),
      ),
    ),
      floatingActionButton: FloatingActionButton(
        backgroundColor: Colors.white,
        onPressed: () {
          // scrollController 通过 animateTo 方法滚动到某个具体高度
          // duration 表示动画的时长，curve 表示动画的运行方式，flutter 在 Curves 提供了许多方式
          state.scrollController.animateTo(0.0,
              duration: Duration(milliseconds: 500),
              curve: Curves.decelerate);
        },
        child: Icon(Icons.arrow_upward_sharp,color: Colors.grey,size: 40,),
      )
  );
}
